package com.wisezone.workflow.dao.hibernate;

import com.wisezone.common.dao.impl.BaseHibernateDaoImpl;
import com.wisezone.workflow.bean.WfVariableInstance;
import com.wisezone.workflow.bean.search.WfVariableInstanceSearch;
import com.wisezone.workflow.dao.WfVariableInstanceDao;
import com.wisezone.workflow.exception.WfDaoException;

/**
 * hiberante 变量实现类
 * @author tss 2009-09-05
 * 
 */
public class WfVariableInstanceDaoImpl extends BaseHibernateDaoImpl implements WfVariableInstanceDao {

    public WfVariableInstanceDaoImpl() {
        super();
    }
   

    /**
     * 获得流程变量实例
     * @param name
     * @param activityInstId
     * @return
     * @throws WfDaoException
     */
	public WfVariableInstance getEntityByActivityInstId(String name,Long activityInstId) throws WfDaoException{
		
		return getEntity(name,null,null,null,activityInstId);
	}
	/**
	 * 获得流程变量实例
	 * @param name
	 * @param activityInstId
	 * @return
	 * @throws WfDaoException
	 */
	public WfVariableInstance getEntityByActivityId(String name,Long activityId) throws WfDaoException{
		
		return getEntity(name,null,null,activityId,null);
	}
 
    /**
     * 获得流程变量实例
     * @param name
     * @param activityInstId
     * @return
     * @throws WfDaoException
     */
	public WfVariableInstance getEntityByProcessDefId(String name,Long processDefId) throws WfDaoException{
		
		return getEntity(name,processDefId,null,null,null);
	}
	
	/**
	 * 获得流程变量实例
	 * @param name
	 * @param processInstId
	 * @return
	 * @throws WfDaoException
	 */
	public WfVariableInstance getEntityByProcessInstId(String name,Long processInstId) throws WfDaoException{
		
		return getEntity(name,null,processInstId,null,null);
	}
	
	
	/**
	 * 获得流程变量实例
	 * @param name
	 * @param processDefId
	 * @param processInstId
	 * @param activityId
	 * @param activityInstId
	 * @return
	 * @throws WfDaoException
	 */
	private WfVariableInstance getEntity(String name,Long processDefId,Long processInstId,Long activityId,Long activityInstId) throws WfDaoException{
		
		WfVariableInstanceSearch searchEntity = new WfVariableInstanceSearch();
		searchEntity.setProcessDefId(processDefId);
		searchEntity.setActivityId(activityId);
		searchEntity.setActivityInstId(activityInstId);
		searchEntity.setProcessInstId(processInstId);
		searchEntity.setName(name);
		return this.get(searchEntity);
	}
	
	

   
   

   
}